home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacTech 1 to 12
/
MacTech-vol-1-12.toast
/
Tools
/
Alpha 6.51b13 ƒ
/
Tcl
/
Modes
/
setextMode.tcl
< prev
next >
Wrap
Text File
|
1996-08-15
|
1KB
|
51 lines
#################################################################################
# Setext file support
#
# Recognize and automatically mark 'setext'-encoded text files, like Tidbits.
#
# (Tom Pollard - October 1994)
#
#================================================================================
if {$startingUp} {
addMode Setx dummySetx {*.stx *.etx} {}
return
}
#===============================================================================
newModeVar Setx autoMark 1 1
#=============================================================================
proc dummySetx {} {}
proc SetxMarkFile {} {
set pat1 {^(-+|=+)$}
set end [maxPos]
set pos 0
set l {}
while {![catch {search -f 1 -r 1 -m 0 -i 1 $pat1 $pos} mtch]} {
set pos1 [lineStart [expr [lindex $mtch 0] - 1]]
set marker [string trimright [eval getText $mtch]]
set text [string trimright [getText $pos1 [nextLineStart $pos1]]]
if {[string length $text] == [string length $marker]} {
if {[string range $marker 0 0] == "-"} {
set text " $text"
}
regsub {/} $text {-} text
set inds($text) $pos1
lappend sects $text
}
set pos [nextLineStart [lindex $mtch 1]]
}
if {[info exists inds]} {
foreach f $sects {
set next [lineStart $inds($f)]
setNamedMark $f $inds($f) $next $next
}
}
}